/** 
 * 文章相关请求模块
 * */ 
import request from "../utils/request";

// 获取文章列表数据
const getArticles = (params) => {
    return request({
        method: 'GET',
        url: '/v1_0/articles',
        params: params
    })
}

// 通过文章id获取文章详情
const getArticleById = (articleId) => {
    return request({
        method: 'GET',
        url: `/v1_0/articles/${articleId}`
    })
}

// 收藏文章
const addCollect = (articleId) => {
    return request({
        method: 'POST',
        url: '/v1_0/article/collections',
        data: {
            target: articleId
        }
    })
}

// 取消收藏文章
const deleteCollect = (articleId) => {
    return request({
        method: 'DELETE',
        url: `/v1_0/article/collections/${articleId}`
    })
}

// 点赞文章
const addLike = (articleId) => {
    return request({
        method: 'POST',
        url: '/v1_0/article/likings',
        data: {
            target: articleId
        }
    })
}

// 取消点赞文章
const deleteLike = (articleId) => {
    return request({
        method: 'DELETE',
        url: `/v1_0/article/likings/${articleId}`
    })
}
export {getArticles, getArticleById, addCollect, deleteCollect, addLike, deleteLike}